﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;

namespace ReportDesign
{
    public partial class ItemsGrid : DevExpress.XtraReports.UI.XtraReport
    {
        public ItemsGrid() : this(new TableAdapterDataFiller()) { }
        public ItemsGrid(ITableReportDataFiller dataFiller)
        {
            InitializeComponent();
            //Name = ReportNames.TableReport;
            //DisplayName = ReportNames.TableReport;
            this.Name = "Test Report";
            DisplayName = "Test Report";
            this.dataFiller = dataFiller;
            BeforePrint += Report_BeforePrint;
        }
        void Report_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            items1.Clear();
            dataFiller.Fill(this);
        }

        #region inner classes
        class TableAdapterDataFiller : ITableReportDataFiller
        {
            public void Fill(ItemsGrid report)
            {
                report.carsTableAdapter1.Fill(report.items1.Cars);
            }
        }
        #endregion

        ITableReportDataFiller dataFiller;
    }
    public interface ITableReportDataFiller
    {
        void Fill(ItemsGrid report);
    }
}
